package com.codes.service.impl;

import com.codes.core.common.enumtype.MessageState;
import com.codes.core.common.enumtype.WorkOrderState;
import com.codes.dao.MessageMapper;
import com.codes.model.Message;
import com.codes.service.MessageSV;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Date 2020/6/10 17:35
 * @Created by peanut
 */
@Service
public class MessageImpl implements MessageSV {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return 0;
    }

    @Override
    public int insert(Message record) {
        return 0;
    }

    @Override
    public int insertSelective(Map map) {
        // 接收人,  工单id  物流id   title  detail  state  根据状态获取 message 内容
        String title = "";
        String detail = "";
        Integer state = MapUtils.getInteger(map,"state");
        if(null != state){
            //  1 2 3 4
            title = WorkOrderState.getLabelByCode(state.shortValue());
            detail = MessageState.getLabelByCode(state.shortValue());
        }
        map.put("title",title);
        map.put("detail",detail);
        return messageMapper.insertSelective(map);
    }

    @Override
    public Message selectByPrimaryKey(Integer id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Map record) {
        return messageMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Message record) {
        return 0;
    }

    @Override
    public List<Map<String, Object>> getMessage(Map map) {
        return messageMapper.getMessage(map);
    }

    @Override
    public Integer getCount(Map map) {
        return messageMapper.getCount(map);
    }
}